package com.myapp.struts.action;

import com.myapp.hibernate.model.Usuario;
import com.myapp.struts.form.ModificarUsuarioForm;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

public class PerfilAction extends org.apache.struts.action.Action {

    /* forward name="success" path="" */
    private static final String SUCCESS = "success";

    @Override
    public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
            throws Exception {

        Usuario usuarioActivo = (Usuario) request.getSession().getAttribute("UsuarioLogado");
        ModificarUsuarioForm formulario = (ModificarUsuarioForm) form;
        formulario.setEmail(usuarioActivo.getEmail());
        formulario.setNombre(usuarioActivo.getNombre());
        formulario.setApellidos(usuarioActivo.getApellidos());
        formulario.setOldPass("");
        formulario.setPass("");
        formulario.setPass2("");
        
        return mapping.findForward(SUCCESS);
    }
}
